<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta content='width=device-width, initial-scale=1.0' name='viewport'>
    <meta content='' name='description'>
    <meta content='Nils Nordman' name='author'>
    <link href='/images/howl.png' rel='shortcut icon'>
    <title>Howl :: howl.io.InputStream</title>
    <link href="/stylesheets/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/syntax.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/howl.css" media="screen" rel="stylesheet" type="text/css" />
    <link href='//fonts.googleapis.com/css?family=Josefin+Slab' rel='stylesheet' type='text/css'>
    <link href='//fonts.googleapis.com/css?family=Open+Sans+Condensed:700' rel='stylesheet' type='text/css'>
  </head>
  <body class='doc doc_api doc_api_io doc_api_io_input_stream'>
    <div class='container'>
      <div class='masthead'>
        <ul class='nav nav-pills'>
          <li>
            <a href='/'>
              <span class='glyphicon glyphicon-home'></span>
              Home
            </a>
          </li>
          <li>
            <a href='/doc/'>
              <span class='glyphicon glyphicon-book'></span>
              Documentation
            </a>
          </li>
          <li>
            <a href='/blog/'>
              <span class='glyphicon glyphicon-bullhorn'></span>
              Blog
            </a>
          </li>
          <li>
            <a href='/contact.html'>
              <span class='glyphicon glyphicon-inbox'></span>
              Contact
            </a>
          </li>
        </ul>
      </div>
      <ol class="breadcrumb"><li><a href="/">Home</a></li><li><a href='../../'>Howl 0.3 Documentation</a></li><li>Api</li><li>Io</li><li>howl.io.InputStream</li></ol>
      <h1 id="howl.io.inputstream">howl.io.InputStream</h1>    <div class="toc">
      <div class="toc-title">
        <span>howl.io.InputStream</span>
      </div>
      <div class="toc-entries">
<div class="toc-group">
<a href="#properties" class="toc-group-header properties">Properties</a>
<li class=""><a href="#is_closed">is_closed</a></li>
</div>
<div class="toc-group">
<a href="#methods" class="toc-group-header methods">Methods</a>
<li class=""><a href="#close">close </a></li>
<li class=""><a href="#read">read </a></li>
<li class=""><a href="#read_async">read_async </a></li>
<li class=""><a href="#read_all">read_all </a></li>
</div>
</div>
</div>
&#x000A;&#x000A;<p>InputStreams are used for reading streaming data. You don&rsquo;t typically create an&#x000A;input stream yourself, but instead get one from an another source, e.g.&#x000A;<a href="process.html#stdout">Process.stdout</a>.</p>&#x000A;&#x000A;<h2 id="properties">Properties</h2>&#x000A;&#x000A;<h3 id="is_closed">is_closed</h3>&#x000A;&#x000A;<p>True if the stream is closed, and false otherwise.</p>&#x000A;&#x000A;<h2 id="methods">Methods</h2>&#x000A;&#x000A;<h3 id="close">close <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Closes the input stream.</p>&#x000A;&#x000A;<h3 id="read">read <span class="arg-list">(num)</span></h3>&#x000A;&#x000A;<p>Reads up to <code>num</code> bytes from the input stream, returning the result as a string.&#x000A;The actual number of bytes read can be smaller than <code>num</code>. Returns <code>nil</code> upon&#x000A;end-of-file. Raises an error upon any IO error.</p>&#x000A;&#x000A;<h3 id="read_async">read_async <span class="arg-list">(num, handler)</span></h3>&#x000A;&#x000A;<p>Reads up to <code>num</code> bytes from the input stream, invoking <code>handler</code> with the&#x000A;result. <code>handler</code> will receive two parameters, the first being a boolean&#x000A;indicating whether the read succeded or not. If the read succeded, the second&#x000A;parameter will be the data read, as a string. Upon end-of-file, this will be&#x000A;<code>nil</code>. If the read failed, the second parameter will be an error string&#x000A;containing information about the failure.</p>&#x000A;&#x000A;<p>Note that just as for <a href="#read">read</a>, the actual number of bytes read can be&#x000A;smaller than <code>num</code>. Also note that the name might give the indication that the&#x000A;alternative, <a href="#read">read</a>, is not asynchronous while <code>read_async</code> is. This is&#x000A;not actually the case, as both are asynchronous in the sense that neither will&#x000A;block Howl; <code>read_async</code> is for the case where you don&rsquo;t want to block execution&#x000A;flow, e.g. when you need to read from multiple input streams at the same time.&#x000A;If this is not the case then <a href="#read">read</a> is likely a better alternative.</p>&#x000A;&#x000A;<h3 id="read_all">read_all <span class="arg-list">()</span></h3>&#x000A;&#x000A;<p>Reads all of the stream&rsquo;s content, returning the result as a string. Raises an&#x000A;error upon any IO error.</p>
      <div class='footer text-muted'>
        <a href='/'>
          <img width="50" height="50" class="footer-logo" src="/images/howl.png" />
        </a>
        <div class='footer-follow'>
          <p>
            <a class='twitter-follow-button' data-lang='en' data-show-count='false' href='https://twitter.com/howleditor' rel='me'>
              Follow @howleditor
            </a>
          </p>
          <p>
            <a class='twitter-share-button' data-count='none' data-hashtags='howleditor' data-lang='en' data-text='The Howl Editor, a general purpose, light-weight customizable editor.' data-url='http://howl.io' href='https://twitter.com/share'>
              Tweet
            </a>
          </p>
        </div>
        <div class='footer-blurb'>
          <div>The Howl editor.</div>
          <div>
            Copyright 2012-2015
            <a class='alert-link' href='https://github.com/nilnor/howl/contributors'>
              The Howl Developers.
            </a>
          </div>
        </div>
      </div>
    </div>
    <script>
      <!-- / GA -->
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-45283282-1', 'howl.io');
      ga('send', 'pageview');
      <!-- / Twitter -->
      !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
      if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
      js.src="//platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
  </body>
</html>
